//
// Created by benxb on 2022/3/6.
//

#include "kitti_reader.h"
#include <common/timer.h>
#include <common/ini_reader.h>
#include <fstream>
#include <filesystem>
#include <iostream>

void KittiReader::ReadSweep(std::vector<float>& x_arr, std::vector<float>& y_arr, std::vector<float>& z_arr) {
    // open data file
    data_io_.open(data_files_[next_index], std::ios::binary | std::ios::in | std::ios::out);
    while (!data_io_.eof()) {
        float x, y, z, i;
        data_io_.read(reinterpret_cast<char *>(&x), sizeof(x));
        data_io_.read(reinterpret_cast<char *>(&y), sizeof(y));
        data_io_.read(reinterpret_cast<char *>(&z), sizeof(z));
        data_io_.read(reinterpret_cast<char *>(&i), sizeof(i));
        x_arr.push_back(x);
        y_arr.push_back(y);
        z_arr.push_back(z);
    }
    next_index++;
    data_io_.close();
}

KittiReader::KittiReader(const std::string &data_dir) : DataReader(data_dir) {
}